
package com.ami.kvm.jviewer.gui;

import com.ami.kvm.jviewer.Debug;
import com.ami.kvm.jviewer.JViewer;
import com.ami.kvm.jviewer.hid.USBMouseRep;
import com.ami.kvm.jviewer.kvmpkts.KVMClient;
import com.ami.kvm.jviewer.kvmpkts.Mousecaliberation;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.Point;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.math.BigDecimal;
import java.net.URL;
import java.util.Hashtable;
import java.util.Iterator;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import javax.swing.BorderFactory;
import javax.swing.Box;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JMenuItem;
import javax.swing.JPopupMenu;
import javax.swing.JSlider;
import javax.swing.JToolBar;
import javax.swing.ToolTipManager;
import javax.swing.border.EtchedBorder;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;

public class JVToolBar extends JToolBar implements MouseListener {
	private JButton altTab;
	private JToolBar m_toolbar;
	public JButton mouseBtn;
	private JButton cdBtn;
	private JButton floppyBtn;
	private JButton hardddiskBtn;
	private JButton kbdBtn;
	private JButton playPauseBtn;
	private JButton fullScreenBtn;
	private JButton videoRecordBtn;
	private JButton powerBtn;
	private JButton hostDisplayBtn;
	private JSlider slider_zoom;
	private JButton zoomBtn;
	private JPopupMenu m_popupMenu;
	private JPopupMenu m_zoomPopupMenu;
	private JButton m_hotKeyBtn;
	private JMenuItem altCtrlDelBtn;
	protected static Hashtable<JButton, String> m_menutoolbar_text = new Hashtable();

	public JButton usersBtn;
	private JPopupMenu userPopupMenu;

	protected JButton createButton(String paramString1, String paramString2, int paramInt1, int paramInt2,
			int paramInt3, int paramInt4) {
		URL localURL;
		if (paramString1 == null) {
			localURL = null;
		} else
			localURL = JViewer.class.getResource(paramString1);
		JButton local1 = new JButton() {
			public Point getToolTipLocation(MouseEvent paramAnonymousMouseEvent) {
				return new Point(getWidth(), getHeight() - 40);
			}
		};
		if (localURL != null) {
			local1.setIcon(new ImageIcon(localURL));
		}
		local1.setToolTipText(paramString2);

		local1.setPreferredSize(new Dimension(paramInt3, paramInt4));
		local1.setMaximumSize(new Dimension(paramInt3, paramInt4));
		local1.setMinimumSize(new Dimension(paramInt3, paramInt4));
		local1.setVisible(true);
		local1.setRequestFocusEnabled(false);
		local1.addMouseListener(this);
		return local1;
	}

	public JVToolBar() {
		this.m_toolbar = new JToolBar();
		ToolTipManager.sharedInstance().setInitialDelay(0);

		this.mouseBtn = createButton("res/Mouse2Btn.png", LocaleStrings.getString("Q_1_JVT"), 23, 23, 33, 33);
		m_menutoolbar_text.put(this.mouseBtn, "Q_1_JVT");

		setCDBtn(createButton("res/CD.png", LocaleStrings.getString("Q_2_JVT"), 23, 23, 33, 33));
		m_menutoolbar_text.put(getCDBtn(), "Q_2_JVT");

		setFloppyBtn(createButton("res/Floppy.png", LocaleStrings.getString("Q_3_JVT"), 23, 23, 33, 33));
		m_menutoolbar_text.put(getFloppyBtn(), "Q_3_JVT");

		setHardddiskBtn(createButton("res/HD.png", LocaleStrings.getString("Q_4_JVT"), 23, 23, 33, 33));
		m_menutoolbar_text.put(getHardddiskBtn(), "Q_4_JVT");

		setKbdBtn(createButton("res/keyboard.png", LocaleStrings.getString("Q_5_JVT"), 23, 23, 33, 33));
		m_menutoolbar_text.put(getKbdBtn(), "Q_5_JVT");

		setFullScreenBtn(createButton("res/Maxi.png", LocaleStrings.getString("Q_6_JVT"), 23, 23, 33, 33));
		m_menutoolbar_text.put(getFullScreenBtn(), "Q_6_JVT");

		setVideoRecordBtn(createButton("res/start_record.png", LocaleStrings.getString("Q_7_JVT"), 23, 23, 33, 33));
		m_menutoolbar_text.put(getVideoRecordBtn(), "Q_7_JVT");

		setPlayPauseBtn(createButton("res/pause.png", LocaleStrings.getString("Q_8_JVT"), 23, 23, 33, 33));
		m_menutoolbar_text.put(getPlayPauseBtn(), "Q_8_JVT");

		setM_hotKeyBtn(createButton("res/Hot-keys.png", LocaleStrings.getString("Q_10_JVT"), 23, 23, 33, 33));
		m_menutoolbar_text.put(getM_hotKeyBtn(), "Q_10_JVT");

		this.usersBtn = createButton("res/user.png", LocaleStrings.getString("Q_11_JVT"), 23, 23, 33, 33);
		m_menutoolbar_text.put(this.usersBtn, "Q_11_JVT");

		setPowerBtn(createButton("res/poweroff.png", LocaleStrings.getString("Q_12_JVT"), 23, 23, 33, 33));
		m_menutoolbar_text.put(getPowerBtn(), "Q_12_JVT");

		setHostDisplayBtn(createButton("res/monitorOn.png", LocaleStrings.getString("Q_21_JVT"), 23, 23, 33, 33));
		m_menutoolbar_text.put(getHostDisplayBtn(), "Q_21_JVT");
		setZoomBtn(createButton("res/zoom.png", LocaleStrings.getString("Q_25_JVT"), 23, 23, 33, 33));
		m_menutoolbar_text.put(getZoomBtn(), "Q_25_JVT");

		this.altCtrlDelBtn = new JMenuItem("Ctrl + Alt + Del");
		this.altCtrlDelBtn.setToolTipText(
				LocaleStrings.getString("Q_13_JVT") + " Ctrl+Alt+Del " + LocaleStrings.getString("Q_14_JVT"));
		this.altCtrlDelBtn.setVisible(true);
		this.altCtrlDelBtn.setRequestFocusEnabled(false);
		this.altCtrlDelBtn.addMouseListener(this);

		this.m_popupMenu = new JPopupMenu();
		this.m_popupMenu.add(this.altCtrlDelBtn);
		this.m_zoomPopupMenu = new JPopupMenu();
		this.m_zoomPopupMenu.add(constructZoomMenu());
		this.m_toolbar.add(getPlayPauseBtn());
		this.m_toolbar.addSeparator();
		this.m_toolbar.add(getFullScreenBtn());
		this.m_toolbar.addSeparator();
		this.m_toolbar.add(getCDBtn());
		this.m_toolbar.add(getFloppyBtn());
		this.m_toolbar.add(getHardddiskBtn());
		this.m_toolbar.addSeparator();
		this.m_toolbar.add(this.mouseBtn);
		this.m_toolbar.add(getKbdBtn());
		this.m_toolbar.addSeparator();
		this.m_toolbar.add(getVideoRecordBtn());
		this.m_toolbar.addSeparator();
		this.m_toolbar.add(getM_hotKeyBtn());
		this.m_toolbar.addSeparator();
		this.m_toolbar.add(getZoomBtn());
		this.m_toolbar.addSeparator();

		this.m_toolbar.add(Box.createHorizontalGlue());
		this.m_toolbar.add(this.usersBtn);
		this.m_toolbar.addSeparator();
		this.m_toolbar.add(getHostDisplayBtn());
		this.m_toolbar.add(Box.createHorizontalStrut(1));
		this.m_toolbar.add(getPowerBtn());
		EtchedBorder localEtchedBorder = new EtchedBorder(1);
		this.m_toolbar.setBorder(localEtchedBorder);
		this.m_toolbar.setFloatable(false);
		this.m_toolbar.repaint();
	}

	protected JSlider constructZoomMenu() {
		if (getSlider_zoom() == null) {
			setSlider_zoom(new JSlider(50, 150));
			getSlider_zoom().setValue(100);
			getSlider_zoom().setMaximumSize(new Dimension(200, 32767));
			getSlider_zoom().setMinimumSize(new Dimension(200, 32767));

			getSlider_zoom().setBorder(BorderFactory.createEtchedBorder());
			getSlider_zoom().setPaintLabels(true);
			getSlider_zoom().setMajorTickSpacing(50);
			getSlider_zoom().setMaximum(150);
			getSlider_zoom().setMinimum(50);
			getSlider_zoom().setMinorTickSpacing(0);
			getSlider_zoom().setToolTipText("100%");

			getSlider_zoom().setFocusable(false);
			getSlider_zoom().addChangeListener(new MyChangeAction());
			getSlider_zoom().setRequestFocusEnabled(false);

			getSlider_zoom().addMouseListener(this);
		}
		return getSlider_zoom();
	}

	public void setZoomLabel(int paramInt) {
		String str = Integer.toString(paramInt);
		JViewerApp.getInstance().getM_wndFrame().getMenu().setZoomLabelText(str + "%");
		getSlider_zoom().setToolTipText(str + "%");
	}

	public void mouseClicked(MouseEvent paramMouseEvent) {
	}

	private class MyChangeAction implements ChangeListener {
		private MyChangeAction() {
		}

		public void stateChanged(ChangeEvent paramChangeEvent) {
			if (!JViewerApp.getInstance().getKVMClient().redirection())
				return;
			int i = JVToolBar.this.getSlider_zoom().getValue();
			JVToolBar.this.setZoomLabel(i);
			BigDecimal localBigDecimal = BigDecimal.valueOf(i, 1);
			JVMenu.m_scale = localBigDecimal.doubleValue() / 10.0D;
			JViewerApp.getInstance().getRCView().setScaleFactor(JVMenu.m_scale, JVMenu.m_scale);

			if ((i >= 50) && (i <= 150)) {
				JViewerApp.getInstance().getJVMenu().SetMenuEnable("Zoom In", Boolean.valueOf(true));
				JViewerApp.getInstance().getJVMenu().getMenuItem("Zoom In").setEnabled(true);
				JViewerApp.getInstance().getJVMenu().SetMenuEnable("Zoom Out", Boolean.valueOf(true));
				JViewerApp.getInstance().getJVMenu().getMenuItem("Zoom Out").setEnabled(true);
			}

			if (i >= 150) {
				JViewerApp.getInstance().getJVMenu().SetMenuEnable("Zoom In", Boolean.valueOf(false));
				JViewerApp.getInstance().getJVMenu().getMenuItem("Zoom In").setEnabled(false);
			}
			if (i <= 50) {
				JViewerApp.getInstance().getJVMenu().SetMenuEnable("Zoom Out", Boolean.valueOf(false));
				JViewerApp.getInstance().getJVMenu().getMenuItem("Zoom Out").setEnabled(false);
			}
			if (JViewerApp.getInstance().getRCView().GetUSBMouseMode() == USBMouseRep.RELATIVE_MOUSE_MODE) {
				JVToolBar.this.changeShowCursorOnZoom();
			}

			if (JVMenu.m_scale != 1.0D) {
				JViewerApp.getInstance().getJVMenu().getMenuItem("ZoomOption None").setSelected(true);
				JViewerApp.getInstance().setZoomOption("ZoomOption None");
			} else {
				JViewerApp.getInstance().getJVMenu().getMenuItem("ActualSize").setSelected(true);
				JViewerApp.getInstance().setZoomOption("ActualSize");
			}
			JViewerApp.getInstance().getRCView().revalidate();
			JViewerApp.getInstance().getRCView().repaint();
		}
	}

	public void mouseEntered(MouseEvent paramMouseEvent) {
	}

	public void mouseExited(MouseEvent paramMouseEvent) {
	}

	public void mousePressed(MouseEvent paramMouseEvent) {
		if (paramMouseEvent.getSource() == this.mouseBtn) {
			if (!JViewerApp.getInstance().getKVMClient().redirection())
				return;
			if (JViewerApp.getInstance().getMainWindow().getMenu().getMenuItem("MouseShowCursor").isSelected()) {
				if (JViewerApp.getInstance().getMainWindow().getMenu().getMenuItem("MouseShowCursor").isEnabled()) {
					JViewerApp.getInstance().OnShowCursor(false);
				}

			} else
				JViewerApp.getInstance().OnShowCursor(true);
		} else {
			Object tianlin;
			if (paramMouseEvent.getSource() == getKbdBtn()) {
				if (!JViewerApp.getInstance().getKVMClient().redirection()) {
					return;
				}
				JVMenu localJVMenu = JViewerApp.getInstance().getJVMenu();

				if (JViewerApp.getInstance().getAutokeylayout() != null) {
					tianlin = JViewerApp.getInstance().getAutokeylayout();
				} else {
					tianlin = new AutoKeyboardLayout();
					JViewerApp.getInstance().setAutokeylayout((AutoKeyboardLayout) tianlin);
				}

				if ((!localJVMenu.getMenuSelected("Auto detect").booleanValue()) && (JVMenu.keyBoardLayout >= 0)) {
					JViewerApp.getInstance().OnSkbrdDisplay(JVMenu.keyBoardLayout);
				} else {
					localJVMenu.notifyMenuStateSelected("Auto detect", true);
					localJVMenu.getMenuItem("NONE").setSelected(true);
					if (((AutoKeyboardLayout) tianlin).getKeyboardType() == 1036) {
						JViewerApp.getInstance().OnSkbrdDisplay(3);
					} else if (((AutoKeyboardLayout) tianlin).getKeyboardType() == 1031) {
						JViewerApp.getInstance().OnSkbrdDisplay(4);
					} else if (((AutoKeyboardLayout) tianlin).getKeyboardType() == 1033) {
						JViewerApp.getInstance().OnSkbrdDisplay(0);
					} else if (((AutoKeyboardLayout) tianlin).getKeyboardType() == 1041) {
						JViewerApp.getInstance().OnSkbrdDisplay(16);
					} else if (((AutoKeyboardLayout) tianlin).getKeyboardType() == 1034) {
						JViewerApp.getInstance().OnSkbrdDisplay(2);
					} else if (((AutoKeyboardLayout) tianlin).getKeyboardType() == 2057) {
						JViewerApp.getInstance().OnSkbrdDisplay(1);
					} else if (((AutoKeyboardLayout) tianlin).getKeyboardType() == 2055) {
						JViewerApp.getInstance().OnSkbrdDisplay(8);
					} else if (((AutoKeyboardLayout) tianlin).getKeyboardType() == 2060) {
						JViewerApp.getInstance().OnSkbrdDisplay(13);
					} else if (((AutoKeyboardLayout) tianlin).getKeyboardType() == 1040) {
						JViewerApp.getInstance().OnSkbrdDisplay(5);
					} else if (((AutoKeyboardLayout) tianlin).getKeyboardType() == 1044) {
						JViewerApp.getInstance().OnSkbrdDisplay(9);
					} else if (((AutoKeyboardLayout) tianlin).getKeyboardType() == 1030) {
						JViewerApp.getInstance().OnSkbrdDisplay(6);
					} else if (((AutoKeyboardLayout) tianlin).getKeyboardType() == 1053) {
						JViewerApp.getInstance().OnSkbrdDisplay(11);
					} else if (((AutoKeyboardLayout) tianlin).getKeyboardType() == 1035) {
						JViewerApp.getInstance().OnSkbrdDisplay(7);
					} else if (((AutoKeyboardLayout) tianlin).getKeyboardType() == 1043) {
						JViewerApp.getInstance().OnSkbrdDisplay(21);
					} else if (((AutoKeyboardLayout) tianlin).getKeyboardType() == 2067) {
						JViewerApp.getInstance().OnSkbrdDisplay(14);
					} else if (((AutoKeyboardLayout) tianlin).getKeyboardType() == 2070) {
						JViewerApp.getInstance().OnSkbrdDisplay(10);
					} else if (((AutoKeyboardLayout) tianlin).getKeyboardType() == 66591) {
						JViewerApp.getInstance().OnSkbrdDisplay(17);
					} else if (((AutoKeyboardLayout) tianlin).getKeyboardType() == 1055) {
						JViewerApp.getInstance().OnSkbrdDisplay(18);
					} else {
						JViewerApp.getInstance().OnSkbrdDisplay(0);
					}
				}
			} else if (paramMouseEvent.getSource() == this.altCtrlDelBtn) {
				if (!JViewerApp.getInstance().getKVMClient().redirection())
					return;
				if (((JViewerApp.getInstance().getJVMenu().getMenuSelected("KeyboardHoldLeftCtrlKey").booleanValue())
						|| (JViewerApp.getInstance().getJVMenu().getMenuSelected("KeyboardHoldRightCtrlKey")
								.booleanValue()))
						&& ((JViewerApp.getInstance().getJVMenu().getMenuSelected("KeyboardHoldLeftAltKey")
								.booleanValue())
								|| (JViewerApp.getInstance().getJVMenu().getMenuSelected("KeyboardHoldRightAltKey")
										.booleanValue()))) {
					return;
				}

				JViewerApp.getInstance().OnKeyboardAltCtrlDel();

			} else if (paramMouseEvent.getSource() == getM_hotKeyBtn()) {
				this.m_popupMenu.show(paramMouseEvent.getComponent(), 0, paramMouseEvent.getComponent().getHeight());
			} else if (paramMouseEvent.getSource() == getPlayPauseBtn()) {
				if (JViewerApp.getInstance().getJVMenu().getMenuItem("VideoResumeRedirection").isEnabled()) {
					JViewerApp.getInstance().OnVideoResumeRedirection();
				} else if (JViewerApp.getInstance().getJVMenu().getMenuItem("VideoPauseRedirection").isEnabled()) {
					JViewerApp.getInstance().setM_userPause(true);
					JViewerApp.getInstance().OnVideoPauseRedirection();
				}

			} else if (paramMouseEvent.getSource() == this.usersBtn) {
				this.userPopupMenu = new JPopupMenu();
				int i = KVMClient.getNumUsers();
				String[] tianlin1 = KVMClient.getUserData();
				if ((tianlin1 != null) && (i != 0)) {

					for (int j = 0; j < i; j++) {
						ImageIcon localImageIcon = null;
						String str1 = tianlin1[j].substring(tianlin1[j].indexOf(":") + 1, tianlin1[j].length()).trim();
						String str2 = tianlin1[j].substring(0, tianlin1[j].indexOf(":") - 1).trim();
						if (Integer.parseInt(str2) == JViewerApp.getInstance().getCurrentSessionId()) {
							URL localURL = JViewer.class.getResource("res/green.png");
							if (localURL != null)
								localImageIcon = new ImageIcon(localURL);
						}
						this.userPopupMenu.add(JViewerApp.getInstance().getJVMenu()
								.createCustomActiveuserMenuItem(Integer.parseInt(str2), str1, localImageIcon));
					}
				}
				this.userPopupMenu.show(paramMouseEvent.getComponent(), 0, paramMouseEvent.getComponent().getHeight());
			} else if (paramMouseEvent.getSource().equals(getPowerBtn())) {

				if (!JViewer.isPowerPrivEnabled()) {
					InfoDialog.showDialog(JViewerApp.getInstance().getMainWindow(),
							LocaleStrings.getString("D_62_JVAPP"), LocaleStrings.getString("A_6_GLOBAL"), 1);

					return;
				}

				if (JViewerApp.getInstance().getM_frame().getMenu().getMenuEnable("Power On Server").booleanValue()) {
					JViewerApp.getInstance().onSendPowerControlCommand("Power On Server");
				} else if (JViewerApp.getInstance().getM_frame().getMenu().getMenuEnable("Immediate Shutdown")
						.booleanValue()) {
					JViewerApp.getInstance().onSendPowerControlCommand("Immediate Shutdown");
				}
			} else if (paramMouseEvent.getSource().equals(getHostDisplayBtn())) {
				if (JViewerApp.getInstance().getM_frame().getMenu().getMenuItem("VideoHostDisplayUnlock").isEnabled()) {
					JViewerApp.getInstance().onSendHostLock((byte) 0);
				} else if (JViewerApp.getInstance().getM_frame().getMenu().getMenuItem("VideoHostDisplayLock")
						.isEnabled()) {
					JViewerApp.getInstance().onSendHostLock((byte) 1);
				}
			} else if (paramMouseEvent.getSource().equals(getZoomBtn())) {
				this.m_zoomPopupMenu.show(paramMouseEvent.getComponent(), 0,
						paramMouseEvent.getComponent().getHeight());
			}
		}
	}

	public void mouseReleased(MouseEvent paramMouseEvent) {
		if (paramMouseEvent.getSource() == getSlider_zoom()) {
			boolean bool = JViewerApp.getInstance().getJVMenu().getMenuSelected("MouseShowCursor").booleanValue();
			if ((getSlider_zoom().getValue() == 100) && (bool)) {
				Mousecaliberation.resetCursor();
			}
		} else if (paramMouseEvent.getSource() == getFullScreenBtn()) {
			if (JViewerApp.getInstance().getMainWindow().getMenu().getMenuItem("VideoFullScreen").isEnabled()) {
				if (JViewerApp.getInstance().getMainWindow().getMenu().getMenuItem("VideoFullScreen").isSelected()) {
					JViewerApp.getInstance().OnVideoFullScreen(false);
					JViewerApp.getInstance().getJVMenu().notifyMenuStateSelected("VideoFullScreen", false);
				} else {
					JViewerApp.getInstance().OnVideoFullScreen(true);
					JViewerApp.getInstance().getJVMenu().notifyMenuStateSelected("VideoFullScreen", true);
				}

			} else {
				getFullScreenBtn().setToolTipText(LocaleStrings.getString("Q_16_JVT"));
			}
		} else if (paramMouseEvent.getSource() == getCDBtn()) {
			invokeVMDialog(0);
		} else if (paramMouseEvent.getSource() == getFloppyBtn()) {
			invokeVMDialog(1);
		} else if (paramMouseEvent.getSource() == getHardddiskBtn()) {
			invokeVMDialog(2);

		} else if (paramMouseEvent.getSource() == getVideoRecordBtn()) {
			if (JViewerApp.getInstance().getMainWindow().getMenu().getMenuItem("VideoRecordStart").isEnabled()) {
				if (JViewerApp.getInstance().getM_videorecord() == null) {
					JViewerApp.getInstance().setM_videorecord(new VideoRecord());
					JViewerApp.getInstance().getM_videorecord().StoreLocation = JViewerApp
							.getInstance().VIDEO_RECORD_DEFAULT_PATH;
					VideoRecord.RecordStopTimer = JViewerApp.getInstance().VIDEO_RECORD_DEFAULT_TIME;
				}
				JViewerApp.getInstance().getM_videorecord().OnVideoRecordStart();
			} else if (JViewerApp.getInstance().getMainWindow().getMenu().getMenuItem("VideoRecordStop").isEnabled()) {
				JViewerApp.getInstance().getJVMenu().notifyMenuStateSelected("VideoRecordStop", false);
				JViewerApp.getInstance().getM_videorecord().OnVideoRecordStop();
			}

			if ((!VideoRecord.Recording_Started) || (!VideoRecord.Record_Processing)) {
				JViewerApp.getInstance().getJVMenu().notifyMenuStateSelected("VideoRecordSettings", false);
			}
		}
	}

	public void changeMacrowsStatusOnPauseResume(boolean paramBoolean) {
		setButtonEnabled(this.mouseBtn, paramBoolean);
		setButtonEnabled(getKbdBtn(), paramBoolean);
		setButtonEnabled(getCDBtn(), paramBoolean);
		setButtonEnabled(getFloppyBtn(), paramBoolean);
		setButtonEnabled(getHardddiskBtn(), paramBoolean);
		setButtonEnabled(getM_hotKeyBtn(), paramBoolean);
		setButtonEnabled(getVideoRecordBtn(), paramBoolean);
		setButtonEnabled(getPowerBtn(), paramBoolean);

		if (KVMSharing.KVM_REQ_GIVEN == 2)
			OnChangeToolbarIconState_KVMPartial();
		if (JViewerApp.getInstance().getZoomOption() == "ActualSize") {
			enableZoomSlider(paramBoolean);
		}
	}

	public void OnChangeToolbarIconState_KVMPartial() {
		boolean bool = false;
		JVMenu localJVMenu = JViewerApp.getInstance().getM_wndFrame().getMenu();
		setButtonEnabled(getKbdBtn(), localJVMenu.getMenuItem("SKBD_English(United States)").isEnabled());
		setButtonEnabled(this.mouseBtn, localJVMenu.getMenuItem("MouseShowCursor").isEnabled());
		setButtonEnabled(getM_hotKeyBtn(), localJVMenu.getMenuItem("KeyboardCtrlAltDel").isEnabled());
		setButtonEnabled(getFloppyBtn(), localJVMenu.getMenuItem("DeviceMediaDialog").isEnabled());
		setButtonEnabled(getCDBtn(), localJVMenu.getMenuItem("DeviceMediaDialog").isEnabled());
		setButtonEnabled(getHardddiskBtn(), localJVMenu.getMenuItem("DeviceMediaDialog").isEnabled());

		if (KVMSharing.KVM_REQ_GIVEN != 2) {
			bool = (localJVMenu.getMenuItem("Immediate Shutdown").isEnabled())
					|| (localJVMenu.getMenuItem("Power On Server").isEnabled());
		}
		setButtonEnabled(getPowerBtn(), bool);
	}

	public void changeToolbarButtonStateOnPowerStatus(boolean paramBoolean) {
		JVMenu localJVMenu = JViewerApp.getInstance().getM_wndFrame().getMenu();
		setButtonEnabled(getPlayPauseBtn(), true);
		setButtonEnabled(getFullScreenBtn(), paramBoolean);
		setButtonEnabled(getKbdBtn(), localJVMenu.getMenuItem("SKBD_English(United States)").isEnabled());
		setButtonEnabled(getFloppyBtn(), localJVMenu.getMenuItem("DeviceMediaDialog").isEnabled());
		setButtonEnabled(getCDBtn(), localJVMenu.getMenuItem("DeviceMediaDialog").isEnabled());
		setButtonEnabled(getHardddiskBtn(), localJVMenu.getMenuItem("DeviceMediaDialog").isEnabled());
		setButtonEnabled(this.mouseBtn, localJVMenu.getMenuItem("MouseShowCursor").isEnabled());

		setButtonEnabled(getM_hotKeyBtn(), localJVMenu.getMenuItem("KeyboardCtrlAltDel").isEnabled());
		if (JViewerApp.getInstance().getZoomOption() == "ActualSize") {
			enableZoomSlider(paramBoolean);
		}
	}

	public void setButtonEnabled(JButton paramJButton, boolean paramBoolean) {
		MouseListener[] arrayOfMouseListener1 = paramJButton.getMouseListeners();
		if (!paramJButton.equals(getPowerBtn()))
			paramJButton.setEnabled(paramBoolean);
		if (paramJButton.equals(getPlayPauseBtn()))
			return;
		MouseListener localMouseListener;
		if (paramBoolean) {
			for (MouseListener localMouseListener1 : arrayOfMouseListener1) {
				if (localMouseListener1.equals(this))
					return;
			}
			paramJButton.addMouseListener(this);
		} else {
			for (MouseListener localMouseListener1 : arrayOfMouseListener1)
				if (localMouseListener1.equals(this))
					paramJButton.removeMouseListener(this);
		}
	}

	public void turnOnPowerButton(boolean paramBoolean) {
		URL localURL;
		if (paramBoolean) {
			localURL = JViewer.class.getResource("res/poweron.png");
			getPowerBtn().setIcon(new ImageIcon(localURL));
			getPowerBtn().setToolTipText(LocaleStrings.getString("Q_17_JVT"));
		} else {
			localURL = JViewer.class.getResource("res/poweroff.png");
			getPowerBtn().setIcon(new ImageIcon(localURL));
			getPowerBtn().setToolTipText(LocaleStrings.getString("Q_18_JVT"));
		}
	}

	public void turnOnHostDisplayButton(boolean paramBoolean) {
		URL localURL;
		if (paramBoolean) {
			localURL = JViewer.class.getResource("res/monitorOn.png");
			getHostDisplayBtn().setIcon(new ImageIcon(localURL));
			getHostDisplayBtn().setToolTipText(LocaleStrings.getString("Q_22_JVT"));
		} else {
			localURL = JViewer.class.getResource("res/monitorOff.png");
			getHostDisplayBtn().setIcon(new ImageIcon(localURL));
			getHostDisplayBtn().setToolTipText(LocaleStrings.getString("Q_23_JVT"));
		}
	}

	public JToolBar getToolBar() {
		return this.m_toolbar;
	}

	public JButton getFloppyBtn() {
		return this.floppyBtn;
	}

	public void setFloppyBtn(JButton paramJButton) {
		this.floppyBtn = paramJButton;
	}

	public JButton getHardddiskBtn() {
		return this.hardddiskBtn;
	}

	public void setHardddiskBtn(JButton paramJButton) {
		this.hardddiskBtn = paramJButton;
	}

	public JPopupMenu getM_popupMenu() {
		return this.m_popupMenu;
	}

	public void changeMacrowsStatus(boolean paramBoolean) {
		this.mouseBtn.setEnabled(paramBoolean);
		getCDBtn().setEnabled(paramBoolean);
		getFloppyBtn().setEnabled(paramBoolean);
		getHardddiskBtn().setEnabled(paramBoolean);
		getKbdBtn().setEnabled(paramBoolean);
		getPlayPauseBtn().setEnabled(paramBoolean);
		getFullScreenBtn().setEnabled(paramBoolean);
		this.altCtrlDelBtn.setEnabled(paramBoolean);

		getVideoRecordBtn().setEnabled(paramBoolean);
		getM_hotKeyBtn().setEnabled(paramBoolean);
		getPowerBtn().setEnabled(paramBoolean);
		getHostDisplayBtn().setEnabled(paramBoolean);

		if (getSlider_zoom() != null) {
			getSlider_zoom().setValue(100);
		}
	}

	public void addHotkeyPoupMenuItem(String paramString) {
		JMenuItem localJMenuItem = new JMenuItem(paramString);
		localJMenuItem.addActionListener(JViewerApp.getInstance().getJVMenu().m_menuListener);
		localJMenuItem.setActionCommand("HK_" + paramString);
		this.m_popupMenu.add(localJMenuItem, 2);
	}

	public void removeHotkeyPoupMenuItem() {
		this.m_popupMenu.removeAll();
		this.m_popupMenu.add(this.altCtrlDelBtn);
	}

	public void changeToolBarItemLanguage() {
		Set localSet = m_menutoolbar_text.entrySet();
		Iterator localIterator = localSet.iterator();
		Object localObject = null;

		while (localIterator.hasNext()) {
			try {
				Map.Entry localEntry = (Map.Entry) localIterator.next();
				localObject = localEntry.getValue();
				JButton localJButton = (JButton) localEntry.getKey();
				localJButton.setToolTipText(LocaleStrings.getString(localObject.toString()));
			} catch (Exception localException) {
				Debug.out.println(localException);
			}
		}
	}

	public void enableZoomSlider(boolean paramBoolean) {
		boolean bool = true;
		if ((paramBoolean)
				&& (JViewerApp.getInstance().getRCView().GetUSBMouseMode() != USBMouseRep.OTHER_MOUSE_MODE)) {
			if (getSlider_zoom().getMouseListeners().equals(null))
				getSlider_zoom().addMouseListener(this);
			setZoomLabel(getSlider_zoom().getValue());
			this.zoomBtn.setToolTipText(LocaleStrings.getString("Q_25_JVT"));
			bool = true;
		} else if (!paramBoolean) {
			resetZoom();
			getSlider_zoom().removeMouseListener(this);
			getSlider_zoom().setToolTipText(LocaleStrings.getString("Q_19_JVT"));
			this.zoomBtn.setToolTipText(LocaleStrings.getString("Q_19_JVT"));
			JViewerApp.getInstance().getM_wndFrame().getMenu().setZoomLabelText(LocaleStrings.getString("Q_20_JVT"));
			bool = false;
		}
		setButtonEnabled(this.zoomBtn, bool);
		getSlider_zoom().setEnabled(bool);
		JViewerApp.getInstance().getJVMenu().notifyMenuStateEnable("Zoom In", bool);
		JViewerApp.getInstance().getJVMenu().notifyMenuStateEnable("Zoom Out", bool);
	}

	public void resetZoom() {
		getSlider_zoom().setValue(100);
		JViewerApp.getInstance().getRCView().revalidate();
		JViewerApp.getInstance().getRCView().repaint();
		JVMenu.m_scale = 1.0D;
		JViewerApp.getInstance().getRCView().setScaleFactor(JVMenu.m_scale, JVMenu.m_scale);
	}

	public void changeShowCursorOnZoom() {
		if (JVMenu.m_scale != 1.0D) {
			URL localURL = JViewer.class.getResource("res/Mouse2Btn-gray.png");
			JViewerApp.getInstance().getM_wndFrame().getToolbar().mouseBtn.setIcon(new ImageIcon(localURL));
			JViewerApp.getInstance().getM_wndFrame().getToolbar().mouseBtn
					.setToolTipText(LocaleStrings.getString("D_48_JVAPP"));
			JViewerApp.getInstance().getJVMenu().notifyMenuStateSelected("MouseShowCursor", false);
			JViewerApp.getInstance().getJVMenu().notifyMenuStateEnable("MouseShowCursor", false);
			JViewerApp.getInstance();
			JViewerApp.showCursor = false;
		} else if (JVMenu.m_scale == 1.0D) {
			JViewerApp.getInstance().getJVMenu().notifyMenuStateEnable("MouseShowCursor", true);
			JViewerApp.getInstance().getM_wndFrame().getToolbar().mouseBtn
					.setToolTipText(LocaleStrings.getString("D_15_JVAPP"));
		}
	}

	public void removeVMediaButtons() {
		this.m_toolbar.remove(getCDBtn());
		this.m_toolbar.remove(getFloppyBtn());
		this.m_toolbar.remove(getHardddiskBtn());
	}

	public void removeHostDisplayStatusButtons() {
		this.m_toolbar.remove(getHostDisplayBtn());
	}

	private void invokeVMDialog(int paramInt) {
		Debug.out.println("MEDIA LICENSE STATUS : " + JViewer.getMediaLicenseStatus());
		if (JViewerApp.getInstance().getMainWindow().getMenu().getMenuItem("DeviceMediaDialog").isEnabled()) {
			if (JViewer.getMediaLicenseStatus() == 1) {
				JViewerApp.getInstance().OnvMedia(paramInt);
			} else {
				InfoDialog.showDialog(JViewer.getMainFrame(), LocaleStrings.getString("F_136_JVM"),
						LocaleStrings.getString("2_4_KVMCLIENT"), 1);
			}
		}
	}

	public JButton getCDBtn() {
		return this.cdBtn;
	}

	public void setCDBtn(JButton paramJButton) {
		this.cdBtn = paramJButton;
	}

	public JButton getKbdBtn() {
		return this.kbdBtn;
	}

	public void setKbdBtn(JButton paramJButton) {
		this.kbdBtn = paramJButton;
	}

	public JButton getPlayPauseBtn() {
		return this.playPauseBtn;
	}

	public void setPlayPauseBtn(JButton paramJButton) {
		this.playPauseBtn = paramJButton;
	}

	public JButton getFullScreenBtn() {
		return this.fullScreenBtn;
	}

	public void setFullScreenBtn(JButton paramJButton) {
		this.fullScreenBtn = paramJButton;
	}

	public JButton getVideoRecordBtn() {
		return this.videoRecordBtn;
	}

	public void setVideoRecordBtn(JButton paramJButton) {
		this.videoRecordBtn = paramJButton;
	}

	public JButton getPowerBtn() {
		return this.powerBtn;
	}

	public void setPowerBtn(JButton paramJButton) {
		this.powerBtn = paramJButton;
	}

	public JButton getHostDisplayBtn() {
		return this.hostDisplayBtn;
	}

	public void setHostDisplayBtn(JButton paramJButton) {
		this.hostDisplayBtn = paramJButton;
	}

	public JSlider getSlider_zoom() {
		return this.slider_zoom;
	}

	public void setSlider_zoom(JSlider paramJSlider) {
		this.slider_zoom = paramJSlider;
	}

	public JButton getM_hotKeyBtn() {
		return this.m_hotKeyBtn;
	}

	public void setM_hotKeyBtn(JButton paramJButton) {
		this.m_hotKeyBtn = paramJButton;
	}

	public void updatePlayPauseButton(boolean paramBoolean) {
		URL localURL;

		if (paramBoolean == true) {
			localURL = JViewer.class.getResource("res/play.png");
			getPlayPauseBtn().setIcon(new ImageIcon(localURL));
			getPlayPauseBtn().setToolTipText(LocaleStrings.getString("Q_9_JVT"));
		} else {
			localURL = JViewer.class.getResource("res/pause.png");
			getPlayPauseBtn().setIcon(new ImageIcon(localURL));
			getPlayPauseBtn().setToolTipText(LocaleStrings.getString("Q_8_JVT"));
		}
		getPlayPauseBtn().setEnabled(true);
	}

	public JButton getZoomBtn() {
		return this.zoomBtn;
	}

	public void setZoomBtn(JButton paramJButton) {
		this.zoomBtn = paramJButton;
	}

	public JPopupMenu getM_zoomPopupMenu() {
		return this.m_zoomPopupMenu;
	}

	public void setM_zoomPopupMenu(JPopupMenu paramJPopupMenu) {
		this.m_zoomPopupMenu = paramJPopupMenu;
	}
}

/*
 * Location:
 * D:\Users\tianlin\Downloads\JViewer.jar!\com\ami\kvm\jviewer\gui\JVToolBar.
 * class Java compiler version: 5 (49.0) JD-Core Version: 0.7.1
 */